﻿using ICSharpCode.AvalonEdit.Highlighting;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Tools.Core.Converters
{
    public class LanguageToSyntaxHighlightingConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            IHighlightingDefinition highlight = null;
            if (value is string language)
            {
                var lang=language.ToLower();
                switch (lang)
                {
                    case "cs":
                        highlight= HighlightingManager.Instance.GetDefinition("C#");break;
                    case "c":
                        highlight = HighlightingManager.Instance.GetDefinition("C"); break;
                    case "cpp":
                        highlight = HighlightingManager.Instance.GetDefinition("CPP"); break;
                    case "java":
                        highlight = HighlightingManager.Instance.GetDefinition("java"); break;
                    case "javascript":
                        highlight = HighlightingManager.Instance.GetDefinition("javascript"); break;
                    case "objective-c":
                        highlight = HighlightingManager.Instance.GetDefinition("objective-c"); break;
                    default:
                        highlight = HighlightingManager.Instance.GetDefinition("text"); break;
                }
            }
            return highlight;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
